package org.discala.samples.complex.recipegenerator

import org.discala.scopes.Create._
import org.discala.scopes.{Singleton}

/**
 * @author Chris Turner
 */
trait RecipeGeneratorModule {

  this: Singleton with AnyRef { val ingredientsSourcePath: () => String } =>

  // Internal container
  class RecipeGeneratorContainer(val sourcePath: () => String) extends RecipeGeneratorComponent
                                                               with IngredientFactoryComponent
                                                               with MethodSelectorComponent {
    val recipeGenerator = singleton(() => new RandomContentRecipeGenerator)
    val factory = singleton(Eager, () => new FileSourceIngredientFactory)
    val methodSelector = singleton(() => new RandomMethodSelector)
  }
  private val container = new RecipeGeneratorContainer(ingredientsSourcePath)

  // Providers
  val recipeGenerator: () => RecipeGenerator = container.recipeGenerator
}